<?php
namespace app\index\controller;

class Index extends Common
{
    public function index($page=1,$keyword="",$type="",$help_id="")
    {
        if($this->request->isAjax()){
            if($type=="del"){
                if($help_id==""){
                    return json(['state'=>0,'msg'=>"缺少"]);
                }
                $rs = db("help")->where("help_id=".$help_id)->delete();
                return json(['state'=>1,'msg'=>"操作成功"]);
            }

        }else{
            $where = " 1 = 1";
            $list = db("help")
                ->alias("a")
                ->field("a.*")
                ->where($where)
                ->paginate(20,true,[
                    'query'     =>['page'=>$page,'keyword'=>$keyword]
                ]);
            $this->assign('keyword', $keyword);
            $this->assign('page', $page);
            $this->assign('list', $list);
            $pageinfo = $list->render();
            $this->assign('pageinfo', $pageinfo);
            return $this->fetch();
        }
    }
    public function add(){
        return $this->view->fetch();
    }
    public function xiao(){
        return $this->view->fetch();
    }
}
